<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>问卷制作</title>
<%@include file="/WEB-INF/jsp/public/commons.jspf"%>
<script src="http://code.jquery.com/jquery-migrate-1.1.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/script/jquery.form.js"></script>
</head>
<body>
<div class="container">
<ol class="breadcrumb">
  <li><a href="home_outerCentre.action">首页</a></li>
  <li class="active">问卷调查</li>
</ol>
</div>
<div class="well well-lg container">

	<!-- 问卷标题显示 -->
	<div class="page-header text-center">
	    <h1>${questionnaire.title}<br/>&nbsp;&nbsp;&nbsp;
	        <small>${questionnaire.description}</small>
	    </h1>
	</div>
	<!-- 题目 -->
	<s:iterator value="questionList" status="status">
		<div style="margin-bottom:20px;">
			<p class="lead">${status.count}、${title}</p>
			<s:iterator value="options">
				<label class='checkbox-inline'>
					<input type='radio' name="option_${question.id}" value="${question.id}_${id}"/>${content}
				</label>
			</s:iterator>
		</div>
	</s:iterator>
	<button type="button" class="btn btn-primary" id="subForm">提交</button>
</div>

<!-- 要提交的表单 -->
<form action="respond_response.action" id="form" method="post">
 	<input type="hidden" name="questionnaireId" value="${questionnaire.id}"/>
 	<input type="hidden" name="respondoptions"/>
</form>
<script>
$(function(){

   	//表单提交
   	$("#subForm").click(function(){
   		//封装数据
   		var fields=$("[type='radio']").serializeArray();
		var inf=new Array();
		$.each(fields,function(index,field){
			inf[index]=field.value;
			index++;
		});
 		$("[name='respondoptions']").val(inf); 
		//提交表单
		$("#form").submit();
   	});
});
</script>
</body>
</html>
